define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Newsend_pinfo, $ionicSlideBoxDelegate, $stateParams,GoPage,$sce,$timeout) {
		$scope.goods_id = $stateParams.goods_id;
		$scope.act_id = $stateParams.act_id;
		$scope.slideIndex = $stateParams.id;
		$scope.product_id = $stateParams.product_id;
		$scope.selectTab = 0;
		$scope.isTransfer = $stateParams.isTransfer; //由此来判断是否显示“商品评价”,"转让详情"是不需要显示“商品评价”的
		$scope.count = null;
		$scope.input = new Array();
		$scope.is_click = false;
		$scope.is_show = new Array();
		//页面激活
		$scope.$on('$ionicView.afterEnter', function() {
			//滑动切换
			if($scope.slideIndex != undefined) {
			$scope.selectTab = $scope.slideIndex;
		};
		$ionicSlideBoxDelegate.$getByHandle('tab-handle').slide($scope.selectTab);
			GoPage.init_top($scope, 44, 0);
			$scope.init_data(); //必须在定义之后
		}, false);
		$scope.activeTab = function(index) {
			$scope.selectTab = index;
			$ionicSlideBoxDelegate.$getByHandle('tab-handle').slide(index);
		};
		//滑动切换
		$scope.slideChanged = function(index) {
			$scope.selectTab = index;
		};
		//加载数据
		$scope.init_data = function() {
			$scope.index = '';
			Newsend_pinfo.get_description($scope.goods_id,$scope.act_id,$scope.product_id, function(data) {
				$scope.rule = data.result.rule;
				$scope.description = $sce.trustAsHtml(data.result.description);
				$scope.bn = data.result.bn;
				$scope.product_bn = data.result.product_bn;
				$scope.brand = data.result.brand;
				$scope.applys = data.result.apply_members;
			})
	};

	}

	controller.$inject = ['$scope', 'Newsend_pinfo', '$ionicSlideBoxDelegate', '$stateParams','GoPage','$sce','$timeout'];

	return app.registerController("newsend_pinfoctrl",controller);
});